/*******************************************************************************
 * Package: com.ruoyi.use.web
 * Type:    UseWeb
 * Date:    2024-03-01 17:41
 *
 * Copyright (c) 2024 LTD All Rights Reserved.
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/
package com.ruoyi.use.web;

import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



/**
 * 功能描述：
 * 通过网关请求示例：http://localhost:8080/cherry/use/get-port
 *
 * @author Songxianyang
 * @date 2024-03-01 17:41
 */
@Slf4j
@RestController
@RequestMapping("/use")
public class UseWeb {

    @Autowired
    private ServletWebServerApplicationContext serverContext;

    @Value("${cherry.info}")
    private Integer unm;
    @Trace
    @GetMapping("/get")
    public Integer get() {
        return unm;
    }

    @GetMapping("/get-port")
    public Integer getPort() {
        return serverContext.getWebServer().getPort();
    }
}
